package com.un.ebs.product.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.un.ebs.product.domain.ProductImage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author LIUBO
 * @since 2019-11-03
 */
@Component
public interface ProductImageMapper extends BaseMapper<ProductImage> {
    @Select("select isnull(max(sort)+1,1) from tb_product_image where product_id=#{productId}")
    int maxSort(@Param("productId") String productId);

    @SqlParser(filter = true)
    @Select("select * from tb_product_image where product_id=#{productId} order by sort")
    List<ProductImage> selectByProductId(@Param("productId") String id);

}
